iT邦幫忙

0

22 : 優化任務優先權與標籤篩選

  • 分享至 

  • xImage
  •  
  1. 優化任務優先權顯示
    • 調整「高中低」不同優先權顏色的顯示方式
    • 保持清單整齊,任務依優先權顏色分組
Color getPriorityColor(String priority) {
 switch (priority) {
   case '高':
     return Colors.red;
   case '中':
     return Colors.yellow;
   case '低':
     return Colors.green;
   default:
     return Colors.grey;
 }
}
  1. 標籤篩選功能確認
    • 點擊「工作、學習、個人、健康」可以正確篩選
    • 點擊「全部」或重複點擊時,清單恢復原狀
void _filterByCategory(String? category) {
setState(() {
  _selectedFilter = category;
});
}

// 在顯示列表時
_todoList.where((item) =>
  _selectedFilter == null || item.category == _selectedFilter)
  1. 程式碼整理與註解
    • 將重複程式整理,增加註解,方便後續擴充功能
    • 確保現有功能可正常運作,並保留擴充接口
// ToDoItem class 中保留 category 與 priority 欄位
class ToDoItem {
String title;
String category; // 工作/學習/個人/健康
String priority; // 高/中/低
bool isDone;

ToDoItem({
 required this.title,
 required this.category,
 this.priority = '中',
 this.isDone = false,
});
}

https://ithelp.ithome.com.tw/upload/images/20251015/20178900sn2lyHjWja.png


圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言